﻿@using KRM.Core.DataObject
@model IEnumerable<KRM.Core.tblKRMOrderAddress>

@{
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    <script src="~/js/stockcontrol.js"></script>
}
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
            <div class="fieldset" style="border: none;">
                <div class="legend">&nbsp;</div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">&nbsp;</label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Name</label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Address Line 1</label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Address Line 2</label>
                    </div>
                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Town</label>
                    </div>

                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Country</label>
                    </div>

                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Postcode</label>
                    </div>

                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Phone 1</label>
                    </div>

                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Phone 2</label>
                    </div>

                </div>
                <div class="row-fluid">
                    <div class="span12">
                        <label class="label-Amend">Mobile</label>
                    </div>

                </div>
            </div>
        </div>
        @foreach (var item in Model)
        {
            var shippingAddress = (bool)item.ShippingAddress ? "shiping" : "billing";
            <div class="span5">
                <form id="fr-@shippingAddress" class="margin0" action="/StockControl/AmendAddressOn" method="POST">
                    <input type="hidden" name="orderID" value="@ViewBag.orderID" />
                    <input type="hidden" name="orderref" value="@ViewBag.orderref" />
                    <input type="hidden" name="oldBillAdd" value="@ViewBag.oldBillAdd" />
                    <input type="hidden" name="oldShipAdd" value="@ViewBag.oldShipAdd" />
                    <input type="hidden" name="ShippingAddress" value="@(item.ShippingAddress.ToString())" />
                    <div class="fieldset">
                        <div class="legend">
                            @if ((bool)item.ShippingAddress)
                            {
                                <span>Shiping Details</span>
                            }
                            else
                            {
                                <span>Billing Details</span>
                                <input type="hidden" name="newShipAdd" value="" />
                            }

                        </div>

                        <div class="row-fluid">
                            <div class="span6">
                                @{
                            var gender = new List<ComboboxStringID>()
                                {
                                    new ComboboxStringID(){Id="Mr",Name = "Mr"},
                                    new ComboboxStringID(){Id="Mrs",Name = "Mrs"},
                                    new ComboboxStringID(){Id="Ms",Name = "Ms"},
                                    new ComboboxStringID(){Id="Miss",Name = "Miss"},
                                    new ComboboxStringID(){Id="Dr",Name = "Dr"},
                                    new ComboboxStringID(){Id="Rev",Name = "Rev"},
                                };
                            ViewBag.Title = new SelectList(gender, "Id", "Name", item.Title);
                                    
                                }
                                @Html.DropDownList("Title", null, new { @class = "input-block-level" })
                            </div>
                        </div>

                        <div class="row-fluid">
                            <div class="span12">
                                <div class="row-fluid">
                                    <div class="span6">
                                        <input type="text"  class="input-block-level"  name="FirstName" value="@item.FirstName" />
                                    </div>
                                    <div class="span6">
                                        <input type="text" class="input-block-level"  name="Surname" value="@item.Surname" />
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text"  class="input-block-level" name="AddressLine1" value="@item.AddressLine1" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text" class="input-block-level"  name="AddressLine2" value="@item.AddressLine2" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text"  class="input-block-level" name="Town" value="@item.Town" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text"  class="input-block-level" name="County" value="@item.County" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text"  class="input-block-level" name="Postcode" value="@item.Postcode" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text" class="input-block-level"  name="Telephone1" value="@item.Telephone1" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text" class="input-block-level"  name="Telephone2" value="@item.Telephone2" />
                            </div>

                        </div>
                        <div class="row-fluid">
                            <div class="span12">
                                <input type="text" class="input-block-level" name="Mobile" value="@item.Mobile" />
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        }
    </div>
    <div class="row-fluid">
        <div class="span12 text-right">

            <input type="button" onclick="$('#fr-shiping').submit();" value="Save" class="btn btn-success" />
        </div>
    </div>
</div>
@{
    ViewBag.Title = ViewBag.orderref;
}